
package com.gamatechno.solodestinationnew.helper;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {

    private static final String DB_NAME = "db_solodes";
    private static final int DB_VER = 1;

    // listing table here

    // end list table

    private static DatabaseHelper instance;
    private static SQLiteDatabase db;

    /**
     * please access this class using getInstance()
     * 
     * @param context
     */
    private DatabaseHelper(Context context) {
        super(context, DB_NAME, null, DB_VER);
    }

    /**
     * <p>
     * Entry Point
     * </p>
     * for access database class
     * <p>
     * Example :
     * </p>
     * <p>
     * DatabaseHelper.getInstance(context).getSomeData();
     * </p>
     * 
     * @param context
     * @return
     */
    public static DatabaseHelper getInstance(Context context) {
        if (instance == null) {
            instance = new DatabaseHelper(context);
            db = instance.getWritableDatabase();
        }
        return instance;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE DATABASE");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS ");
        onCreate(db);
    }

    /**
     * dummy insert data
     */
    public void insertData() {
        ContentValues values = new ContentValues();
        values.put("data", "data apa");
        db.insert("table", null, values);
    }
}
